{include file='public/meta'}
<title>数据表备份 - 数据管理 - 木鱼内容管理系统	</title>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
		    <div style="padding: 10px; background-color: #FAFAFA;">
              <div class="layui-row layui-col-space15">
                <div class="layui-col-md13">
                <div class="layui-card">
                    <div class="layui-card-header">操作台&nbsp; &nbsp; &nbsp;<span style="color:red;display:inline-block;">Tips:默认备份文件不启用压缩!</span></div>
                    <div class="layui-card-body">
					  <a class="layui-btn layui-btn-xs" onclick="backup('{$table}')" href="javascript:;">备份当前</a>  
                    </div>   
                    </div>
                </div>
                </div>  
            </div> 

			<div class="layui-card-body">
			    <span style="display:inline-block;">历史备份-共有数据：{$list|count} 条</span>
			    {if condition="$table == 'database'"}
			    <span style="display:inline-block;float:right;color:red;">整表还原,数据过多可能响应时间过长,请勿重复点击还原!</span>
                {/if}
            <div class="layui-table-body layui-table-main">
                <table class="layui-table" id="LAY-user-front-submit">
					<thead>
						<tr>
							<th>
								<div class="layui-table-cell" align="center"><span>备份名称</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>备份时间</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>文件大小</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>文件类型</span></div>
							</th>
							<th>
								<div class="layui-table-cell" align="center"><span>操作</span></div>
							</th>
						</tr>
					</thead>
					<tbody>
					    {foreach $list as $val}
						<tr align="center">
							<td>{$val.name}</td>
							<td>{$val.time|date='Y/m/d'}</td>
							<td>{:format_size($val.size)}</td>
							<td>{$val.compress}</td>
							<td align="center" data-off="true" class="layui-table-col-special">
								<div class="layui-table-cell">
								    <a class="layui-btn layui-btn-xs layui-btn-warm" onclick="restore('{$val.name}','{$table}')" href="javascript:;">还原</a>
								    <a class="layui-btn layui-btn-xs layui-btn-danger" onclick="del('{$val.name}','{$table}')" href="javascript:;">删除</a>
								</div>
							</td>
						</tr>
						{/foreach}
					</tbody>
				</table>
            </div>
			</div>

		</div>
	</div>


	<!-- 低部区域 -->
	{include file='public/footer'}
	<script>
		layui.config({
			base: '__ADMINST__layuiadmin/' //静态资源所在路径
				,
			version: new Date().getTime()
		}).extend({
			index: 'lib/index' //主入口模块
		}).use(['index', 'table']);
	
	
	//单表备份
	function backup(tablename){
	    $.post("{:url('admin/Database/dbbackup')}",{tb:tablename},function(res){
	        layer.msg(res.msg,{time:2000},function(){
	            location.reload();
	        });
	    },'json');
	}
	//单表备份还原
	function restore(name,tablename){
	    $.post("{:url('admin/Database/restore')}",{name:name,tb:tablename},function(res){
	        layer.msg(res.msg,{time:2000},function(){
	            location.reload();
	        });
	    },'json');
	}
	//单表备份删除
	function del(name,tablename){
	    $.post("{:url('admin/Database/sqldel')}",{name:name,tb:tablename},function(res){
	        layer.msg(res.msg,{time:2000},function(){
	            location.reload();
	        });
	    },'json');
	}
	</script>
</body>
</html>